﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using MyWindowsMediaPlayer.Libs.ViewModel;
using MyWindowsMediaPlayer.Libs.Mediator;
using MyWindowsMediaPlayer.Models;
using System.Windows.Forms;

namespace MyWindowsMediaPlayer.ViewModels
{
	public class MediaViewModel : ViewModelBase
	{
		#region Members

		MediaModel _item;
		Mediator _mediator;
		ICommand _selectCmd;

		#endregion

		#region Constructor

		public MediaViewModel ( MediaModel item, Mediator mediator )
		{
			this._item = item;
			this._mediator = mediator;
		}

		#endregion

		#region Accessors

		public Uri ItemPath
		{
			get { return this._item.ItemPath; }
			set
			{
				this._item.ItemPath = value;
				OnPropertyChanged("ItemPath");
			}
		}

		public String PicturePath
		{
			get { return this._item.PicturePath; }
			set
			{
				this._item.PicturePath = value;
				OnPropertyChanged("PicturePath");
			}
		}
		public String Name
		{
			get { return this._item.Name; }
			set
			{
				this._item.Name = value;
				OnPropertyChanged("Name");
			}
		}

		public String Type
		{
			get { return this._item.Type; }
			set
			{
				this._item.Type = value;
				OnPropertyChanged("Type");
			}
		}

		public int Notation
		{
			get { return this._item.Notation; }
			set
			{
				this._item.Notation = value;
				OnPropertyChanged("Notation");
			}
		}

		#endregion

		#region Commands

		public ICommand SelectCmd
		{
			get 
			{
				if (this._selectCmd == null)
					this._selectCmd = new RelayCommand(( ) => this.SelectedItems());
				return this._selectCmd;
			}
		}

		private void SelectedItems ( )
		{
			this._mediator.NotifyColleagues(MediatorMessage.CenterItemSelected, this);
		}
		#endregion
	}
}
